$primary-color: #1890ff;
$text-color: #fff;
$bg-color: rgba(0, 0, 0, 0.85);
$toolbar-bg: rgba(0, 0, 0, 0.4);
$border-radius: 4px;
$transition: all 0.3s ease;

.image-preview-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: $bg-color;
    z-index: 999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    animation: fadeIn 0.3s forwards;
    
    @keyframes fadeIn {
        to { opacity: 1; }
    }
}

.image-preview-container {
    position: relative;
    width: 100%;
    max-width: 90vw;
    height: 90vh;
    display: flex;
    
    .nav-button {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        width: 44px;
        height: 44px;
        background: rgba(0, 0, 0, 0.3);
        border-radius: 50%;
        border: none;
        outline: none;
        cursor: pointer;
        display: flex;
        justify-content: center;
        align-items: center;
        z-index: 1000;
        opacity: 0;
        transition: $transition;
        
        &.prev {
        left: 10px;
        }
        
        &.next {
        right: 10px;
        }
        
        &:hover {
        background: rgba(0, 0, 0, 0.6);
        opacity: 1;
        }
        
        .icon {
        display: block;
        width: 24px;
        height: 24px;
        position: relative;
        
        &::before, &::after {
            content: '';
            position: absolute;
            background: white;
        }
        
        &.icon-left {
            &::before {
            width: 16px;
            height: 3px;
            left: 0;
            top: 10px;
            transform: rotate(-45deg);
            transform-origin: left bottom;
            }
            
            &::after {
            width: 16px;
            height: 3px;
            left: 0;
            top: 20px;
            transform: rotate(45deg);
            transform-origin: left top;
            }
        }
        
        &.icon-right {
            &::before {
            width: 16px;
            height: 3px;
            right: 0;
            top: 10px;
            transform: rotate(45deg);
            transform-origin: right bottom;
            }
            
            &::after {
            width: 16px;
            height: 3px;
            right: 0;
            top: 20px;
            transform: rotate(-45deg);
            transform-origin: right top;
            }
        }
        }
        
        &.disabled {
        display: none;
        }
    }
    
    &:hover .nav-button {
        opacity: 1;
    }
    
    .image-viewport {
        width: 100%;
        height: 100%;
        overflow: hidden;
        position: relative;
        
        .slide {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        
        &:not(.active) {
            visibility: hidden;
        }
        
        .image-container {
            position: relative;
            max-width: 100%;
            max-height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
            cursor: grab;
            
            &:active {
            cursor: grabbing;
            }
            
            img {
            max-width: 100%;
            max-height: 100%;
            object-fit: contain;
            transition: opacity 0.3s ease;
            }
            
            .image-loader {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            color: white;
            display: flex;
            flex-direction: column;
            align-items: center;
            
            .spinner {
                width: 30px;
                height: 30px;
                border: 3px solid rgba(255, 255, 255, 0.3);
                border-radius: 50%;
                border-top-color: white;
                animation: spin 1s linear infinite;
                margin-bottom: 10px;
                
                @keyframes spin {
                to { transform: rotate(360deg); }
                }
            }
            }
        }
        }
    }
    
    .toolbar {
        position: absolute;
        bottom: 30px;
        left: 50%;
        transform: translateX(-50%);
        background: $toolbar-bg;
        border-radius: $border-radius;
        padding: 6px;
        display: flex;
        z-index: 1000;
        
        .toolbar-button {
        background: none;
        border: none;
        width: 36px;
        height: 36px;
        margin: 0 3px;
        border-radius: $border-radius;
        display: flex;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        transition: $transition;
        
        .icon {
            display: flex;
            width: 20px;
            height: 20px;
            align-items: center;
            justify-content: center;
            position: relative;
            color: var(--text-primary);
            svg{
                width: 18px;
                height: 18px;
            }
        }
        
        &:hover {
            background: rgba(255, 255, 255, 0.15);
        }
        
        .icon-close {
            &::before {
                width: 16px;
                height: 2px;
                top: 9px;
                left: 2px;
                transform: rotate(45deg);
            }
            
            &::after {
                width: 16px;
                height: 2px;
                top: 9px;
                left: 2px;
                transform: rotate(-45deg);
            }
        }
        }
        
        .close-button {
        &:hover {
            background: rgba(255, 0, 0, 0.3);
        }
        }
    }
    
    .image-indicator {
        position: absolute;
        bottom: 85px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.4);
        color: $text-color;
        padding: 4px 12px;
        border-radius: $border-radius;
        font-size: 14px;
        z-index: 1000;
    }
    
    .thumbnail-nav {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 80px;
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 10px;
        overflow-x: auto;
        overflow-y: hidden;
        z-index: 1000;
        
        &::-webkit-scrollbar {
        height: 4px;
        }
        
        &::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.3);
        border-radius: 2px;
        }
        
        .thumbnail {
        width: 60px;
        height: 60px;
        margin: 0 5px;
        cursor: pointer;
        position: relative;
        opacity: 0.6;
        transition: $transition;
        flex-shrink: 0;
        
        &:hover {
            opacity: 0.9;
            transform: translateY(-5px);
        }
        
        &.active {
            opacity: 1;
            transform: translateY(-5px);
            
            .active-border {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            border: 2px solid $primary-color;
            border-radius: $border-radius;
            }
        }
        
        img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            border-radius: $border-radius;
        }
        }
    }
    }

    @media (max-width: 768px) {
    .image-preview-container {
        max-width: 100vw;
        height: 100vh;
        
        .nav-button {
        width: 36px;
        height: 36px;
        
        .icon {
            width: 18px;
            height: 18px;
        }
        }
        
        .toolbar {
        bottom: 20px;
        
        .toolbar-button {
            width: 32px;
            height: 32px;
            margin: 0 2px;
        }
        }
        
        .image-indicator {
        bottom: 75px;
        }
        
        .thumbnail-nav {
        height: 70px;
        
        .thumbnail {
            width: 50px;
            height: 50px;
        }
        }
    }
}